#include "widget.h"
#include "ui_widget.h"
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->lineEdit_name->setPlaceholderText("请输入姓名");
    // 设置一个清空按钮
    ui->lineEdit_name->setClearButtonEnabled(true);
    ui->lineEdit_password->setPlaceholderText("请输入密码");
    ui->lineEdit_password->setClearButtonEnabled(true);
    // 设置密码的显示方式
    ui->lineEdit_password->setEchoMode(QLineEdit::Password); // 设置成显示密码的显示方式(默认是星号)
    ui->lineEdit_phone->setPlaceholderText("请输入电话");
    ui->lineEdit_phone->setClearButtonEnabled(true);
    // 手机号码是有固定格式的         此处的“0”表示只能输入数字
    ui->lineEdit_phone->setInputMask("000-0000-0000"); // 一般的手机号码的格式
    // InputMask会对输入的内容进行简单校验
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QString gender;
    if (ui->radioButton_male->isChecked()) {
        gender = "男";
    } else if (ui->radioButton_female->isChecked()) {
        gender = "女";
    }
    // 打印出用户输入的信息
    qDebug() << "姓名: " << ui->lineEdit_name->text();
    qDebug() << "性别: " << gender;
    qDebug() << "电话: " << ui->lineEdit_phone->text();

}
